<?php
if(!isset($GLOBALS['_vars'])) $GLOBALS['_vars'] = array(); 
$fields = array();
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $cfg_soft_lang; ?>">
<title>认领详情列表</title>
<link rel="stylesheet" type="text/css" href="css/base.css">
<script language="javascript" src="../include/js/dedeajax2.js"></script>
<script language="javascript" src="js/ieemu.js"></script>
<script language="javascript" src="js/context_menu.js"></script>
<script language="javascript" src="js/main.js"></script>
<script language="javascript" src="js/list.js"></script>
</head>


<body leftmargin="8" topmargin="8" background='images/allbg.gif' onLoad="ContextMenu.intializeContextMenu()">

<!--  快速转换位置按钮  -->
<table width="98%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ccd9b9" align="center">
<tr>
 <td height="26" background="images/newlinebg3.gif">
  <table width="98%" border="0" cellspacing="0" cellpadding="0">
  <tr>
  <td align="center">
 </td>
 </tr>
</table>
</td>
</tr>
</table>
  
<!--  内容列表   -->
<form name="form2">
<table width="98%" border="0" cellpadding="2" cellspacing="1" bgcolor="#CFCFCF" align="center" style="margin-top:8px">
<tr bgcolor="#E7E7E7" >
	<td height="28" colspan="12" background="images/tbg.gif" style="padding-left:10px;">
	◆ 认领详情列表
	</td>
</tr>
<tr align="center" bgcolor="#FBFCE2" height="25">
	<td width="6%">ID</td>
	<td width="4%">选择</td>
	<td width="12%">订单号</td>
	<td width="8%">姓名</td>
	<td width="10%">电话</td>
	<td width="6%">认领年数</td>
	<td width="6%">认领棵树</td>
	<td width="8%">发票状态</td>
	<td width="12%">邮箱</td>
	<td width="4%">支付状态</td>
	<td width="4%">收货方式</td>
	<td colspan="2" width="20%">下单时间</td>
</tr>
<?php
$atts = array();
$atts['tagname'] = 'datalist';
$blockValue = $this->refObj->GetArcList($atts,$this->refObj,$fields); 
if(is_array($blockValue)){
foreach( $blockValue as $key=>$fields )
{
?>
<tr align='center' bgcolor="#FFFFFF" height="26" align="center" onMouseMove="javascript:this.bgColor='#FCFDEE';" onMouseOut="javascript:this.bgColor='#FFFFFF';">
	<td nowrap>
		<?php echo $fields['id']; ?>
	</td>
	<td>
		<input name="arcID" type="checkbox" id="arcID" value="<?php echo $fields['id']; ?>" class="np" />
	</td>
	<td align='left'><span id="arc<?php echo $fields['id']; ?>"><?php echo $fields['order_sn']; ?></span></td>
	<td><?php echo $fields['name']; ?></td>
	<td><?php echo $fields['tel']; ?></td>
	<td><?php echo $fields['years']; ?></td>
	<td><?php echo $fields['number']; ?></td>
	<td><?php if($fields['invoicestate'] == '0'){ ?> 未开 <?php
}
else{
?>  
      已开
    <?php } ?></td>
	<td> <?php 
$a = $fields['user_id'];
$query = "select * from orchard_user where id='$a' ";
$row=$dsql->GetOne($query);
echo $row['email'];
?></td>
	<!-- <td><?php if($fields['mailingpackage'] == 'A'){ ?>  10斤/次 <?php
}
else{
?>  
       30斤/次
    <?php } ?></td> -->
	<td><?php if($fields['paystate'] == '0'){ ?> 未付 <?php
}
else{
?>  
      已付
    <?php } ?></td>
	<td><?php if($fields['deliveryway'] == '1'){ ?> 邮寄 <?php
}
else{
?>
	  采摘
	<?php } ?></td>
	<td colspan="2"><?php echo $fields['create_time']; ?></td>
</tr> <tr align='center' style="color: #666;" bgcolor="#efefef" height="26" align="center" >
<td colspan="2"></td>
<td>果树编号</td>
<td>挂牌状态</td>
<td style="display: none;">邮寄套餐</td>
<td>认领年数</td>
<td style="display: none;">应邮寄数</td>
<td style="display: none;">已邮寄数</td>
<td>收件人</td>
<td>联系电话</td>
<td colspan="3">邮寄地址</td>
<td colspan="2">操作</td>
</tr>	 <?php 
$a = $fields['id'];
$query = "select * from orchard_order_tree where order_id='$a' ";
 $dsql->SetQuery($query);
 $dsql->Execute();
 while($row = $dsql->GetArray()){
?>

<tr align='center' style="color: #666;" bgcolor="#ececec" height="26" align="center" >
	<td colspan="2"></td>
	<td><a  onclick="openK('<?php echo $row['tree_sn'];?>')"><u><?php echo $row['tree_sn'];?></u></a></td>
	<td><?php echo $row['is_listing']?'完成挂牌':'尚未挂牌';?></td>
	<td style="display: none;"><?php  if($row['mailingpackage']=='A') echo '10斤/次'; else echo '30斤/次'?></td>
	<td><?php echo $row['years'];?></td>
	<td style="display: none;"><?php echo $row['shouldnums'];?></td>
	<td style="display: none;"><?php echo $row['alreadynums'];?></td>
	<td><?php echo $row['name'];?></td>
	<td><?php echo $row['phone'];?></td>
	<td colspan="3"><?php echo $row['address'];?></td>
	<td colspan="2">
	    <input type="button" value="邮寄" onclick="dopost('<?php echo $row['tree_sn'];?>')" >
	    <input type="button" value="<?php echo $row['is_listing']?'取消挂牌':'挂牌';?>" onclick="dolisting('<?php echo $row['id'];?>')" >
	</td>
	
	
	
</tr>
<?php }
}
}?>
<tr bgcolor="#ffffff">
<td height="36" colspan="12">
	&nbsp;
	<a href="javascript:selAll()" class="coolbg">全选</a>
	<a href="javascript:noSelAll()" class="coolbg">取消</a>

 <a href="javascript:delArc(0)" class="coolbg">&nbsp;删除&nbsp;</a>
	<?php if($channelid==1) echo "	<a href=\"javascript:kwArc(0)\" class=\"coolbg\">&nbsp;自动关键字&nbsp;</a>\r\n"; ?>
 
</td>
</tr>
</form>
<tr align="right" bgcolor="#F9FCEF">
	<td height="36" colspan="12" align="center">
		<?php
$atts = array();
$atts['tagname'] = 'pagelist';
$atts['listsize'] = '3';
 echo $this->refObj->GetPageList($atts,$this->refObj,$fields); 
?>

	</td>
</tr>
</table>

<!--  搜索表单  -->
<form name='form3' action='content_list.php' method='get'>
<input type='hidden' name='dopost' value='listArchives' />
<table width='98%'  border='0' cellpadding='1' cellspacing='1' bgcolor='#cfcfcf' align="center" style="margin-top:8px">
  <tr bgcolor='#EEF4EA'>
    <td background='images/wbg.gif' align='center'>
      <table border='0' cellpadding='0' cellspacing='0' height="32">
        <tr>
          <td width='160'>
          <select name='cid' style='width:150px'>
          <option value='0'>选择栏目...</option>
          	<?php echo $GLOBALS['optionarr']; ?>
          </select>
        </td >
        <td nowrap>
          关键字：
        </td>
        <td width='130'>
          	<input type='text' name='keyword' value='<?php echo $GLOBALS['keyword']; ?>' style='width:120px' />
        </td>
        <td width='90'>
    		<select name='orderby' style='width:80px'>
            <option value='id'>排序...</option>
            <option value='pubdate'>更新时间</option>
            <option value='sortrank'>置顶权值</option>
            <option value='click'>点击量</option>
            <option value='scores'>评论积分</option>
            <option value='lastpost'>最后评论</option>
      	</select>
      </td>
      <td width='90'>
    		<select name='flag' style='width:80px'>
            <option value=''>属性...</option>
            <?php echo $GLOBALS['flagsArr']; ?>
      	</select>
      </td>
       <td>
          <input name="imageField" type="image" src="images/button_search.gif" width="60" height="22" border="0" class="np" />
       </td>
      </tr>
     </table>
   </td>
  </tr>
</table>
	
</form>

</body>
</html>
 
	<script src="js/jquery-1.11.0.min.js" type="text/javascript"></script>
	<script src="js/jquery.dialog.js"></script>
	<link rel="stylesheet" type="text/css" href="css/dialog.css">
	
		<script>
		  //挂牌函数
		  function dolisting(id){
		      if(!confirm('确定要做此操作吗？')){
			return false;
		}
        $.ajax({
				type:"post",
				url:"ajax.php",
				async:false,
				data:{
				    id:id,
				    dopost:'set_listing'
				    
				},
				dataType:'json',
				success:function (v) {
					//认领成功
					if (v.status==200){
					  alert(v.msg);
					  location.reload();
					}else{
						alert(v.msg);
					}
				},
				error:function (msg) {
					
					console.log(msg)
				}
			})
		      
		  }
		
        	function openK(id){
        	  var html = "<table><tr bgcolor='#EEF4EA'><td>id</td><td >邮寄单号</td><td >物流名称</td><td>快递时间</td></tr>";
        	  $.ajax({
				type:"post",
				url:"ajax.php",
				async:false,
				data:{
				    tree_sn:id,
				    dopost:'get_post_list'
				    
				},
				dataType:'json',
				success:function (v) {
					//认领成功
					if (v.status==200){
					   
					    if(v.list.length==0){
					         html += "<tr><td colspan='4'><font color='red'>暂无邮寄信息</font></td></tr>" 
					    }
					    v.list.forEach(function(item){
					       html += "<tr><td>"+item.id+"</td><td>"+item.post_number+"</td><td>"+item.post_type+"</td><td>"+item.post_time+"</td></tr>" 
					        
					   })
					
					}
					
				},
				error:function (msg) {
					
					console.log(msg)
				}
			})
        	html += "</table>";
        
        	$.sendConfirm({
        	    hideHeader: true,
        	    withIcon: true,
        	    desc:html,
        	    button: {
        	      confirm: '确定',
        	      cancel: null,
        	    },
        	    onConfirm: function() {
        	      console.log('点击确认！');
        	    },
        	    onCancel: function() {
        	      console.log('点击取消！');
        	    },
        	    onClose: function() {
        	      console.log('点击关闭！');
        	    }
        	  });
        	}
        //邮寄
        function dopost(tree_sn){
        
     	  
     
     	$.sendConfirm({
     	          title: '果树编号:'+tree_sn+'苹果邮寄',
     	           content: '<form method="post" id="set_post"><div id="addIpBox">' + '<div class="frm-item"><input type="hidden" value="' +tree_sn+ '" name="tree_sn" /><div class="frm-label"><span class="requireIcon">*</span> 快递单号:</div>' + '<input type="text" class="frm-input" name="post_number" placeholder="请填写有效的快递单号">' + '</div>' + '<div class="frm-item">' + '<div class="frm-label"><span class="requireIcon">*</span> 物流名称:</div>' + '<input type="text" class="frm-input" name="post_type" placeholder="最多15个汉字">' + '<div class="msg-box j_msgDesc hide"></div>' + '</div>' + '<div class="frm-item">' + '<div class="frm-label"><span class="requireIcon">*</span> 快递时间:</div>' + '<input type="text" class="frm-input" name="post_time" placeholder="最多10个汉字">' + '<div class="msg-box j_msgOperator hide"></div>' + '</div>' + '</div><input value="set_post" name="dopost" type="hidden"><button id="subbtn" type="submit">确认邮寄</button></form>',
     	           button: {
     	             confirm: '确认',
     	             cancel: '取消'
     	           },
     	    onConfirm: function() {
     	      $("#set_post").submit();
     	     
     	      console.log('点击确认！');
     	    },
     	    onCancel: function() {
     	      console.log('点击取消！');
     	    },
     	    onClose: function() {
     	      console.log('点击关闭！');
     	    }
     	  });
     	}
     	
     	
     $(function(){
       $(document).on("submit","#set_post",function(){
           
           $.ajax({
			type:"post",
			url:"ajax.php",
			async:false,
			data:$("#set_post").serialize(),
			dataType:'json',
			success:function (v) {
				if (v.status==200){
				    alert(v.msg);
				}else{
					alert(v.msg);
					return false;
				}
			},
			error:function (msg) {
				console.log(msg)
			}
		})
		return false;
       })
       
     })
     
        
		
	
    


	</script>
<style type="text/css">
	/* 通过果树编号来查看快递信息 */
	#dialogConfirmBox{
		
	}
	#dialogConfirmBox .dialog-body{
		padding:30px;
		box-sizing: border-box;
	}
	#dialogConfirmBox .dialog-confirm{
		width: 100%;
		padding: 0;
		height: auto;
	}
	#dialogConfirmBox .dialog-desc{
		width: 100%;
		height: auto;
	}
	#dialogConfirmBox .dialog-desc table{
		width: 100%;
		height: auto;
	}
	#dialogConfirmBox .dialog-desc table tr:nth-child(2n){
		background: #efefef;
	}
	#dialogConfirmBox .dialog-desc table tr td{
		line-height: 2;
		text-align: center;
	}
	#dialogConfirmBox .dialog-desc table tr td:nth-child(1){
		width: 10%;
	}
	#dialogConfirmBox .dialog-desc table tr td:nth-child(2){
		width: 30%;
	}
	#dialogConfirmBox .dialog-desc table tr td:nth-child(3){
		width: 30%;
	}
	#dialogConfirmBox .dialog-desc table tr td:nth-child(4){
		width: 30%;
	}
	#dialogConfirmBox .dialog-buttonBox{
		text-align: center;
	}
	/* 通过邮寄查看 */
	#addIpBox{
		width: 100%;
		height: auto;
	}
	#addIpBox .frm-item{
		width: 100%;
		height: auto;
		display: flex;
		line-height: 2;
		padding: 0.1rem 0;
		box-sizing: border-box;
		margin-bottom: 0.8rem;
		align-items: center;
	}
	#addIpBox .frm-item .frm-label{
		font-size: 14px;
		color: #666;
		line-height: 1;
		margin-right: 2%;
	}
	#addIpBox .frm-item input.frm-input{
		font-size: 14px;
		color: #666;
		width: 60%;
		outline: none;
	    border: 1px solid #cccccc;
		line-height: 1;
	    background: transparent;
		
	}
	#addIpBox .frm-item .frm-input::placeholder{
		color: #c2bebe;
		font-size: 14px;
		line-height: 1;
	}
	#subbtn{
	    width: 98px;
	    height: 29px;
	    font-size: 12px;
	    line-height: 29px;
		border: none;
		background-color: #6f55c0;
		color: #fff;
		text-align: center;
		text-decoration: none;
		opacity: 1;
		position: absolute;
		bottom: 0;
		left: 122px;
	}
</style>